{% extends "templates/base.phtml" %}
{%block content%}
{% if wxc is defined %}
<div class="page-content-wrap">
    <div class="row">
        <div class="col-md-12">
            <div class="panel panel-default tabs">
                {%include 'include/wx_tabs' with ['action':'reply']%}
                <div class="panel-body tab-content">
                    <div class="tab-pane active">
                        <div class="col-md-12">
                            <h3>图文回复</h3>
                            <div class="panel panel-default">
                                <div class="panel-body def-pan-bd">
                                    <div class="col-title col-md-12 col-xs-12 form-horizontal">
                                        <div class="form-group">
                                            <label class="col-md-2 col-xs-4 control-label pull-left">请选择智能回复类型：</label>
                                            <div class="col-md-4 col-xs-4 pull-left">
                                                <select class="form-control select">
                                                    <option>图文回复</option>
                                                    <option>首次关注回复</option>
                                                    <option>文本回复</option>
                                                    <option>多图文回复</option>
                                                </select>
                                            </div>
                                            <div class="col-md-2 col-xs-2 pull-right">
                                                <a class="btn btn-success " href="/admin/appwx/addimg">新建一条</a>
                                            </div>
                                        </div>

                                    </div>

                                    <div class="col-bd col-md-12 col-xs-12">
                                        <div class="table-responsive">
                                            <table class="table table-bordered">
                                                <thead>
                                                <tr>
                                                    <th>编号</th>
                                                    <th>标题</th>
                                                    <th>关键词</th>
                                                    <th>浏览次数</th>
                                                    <th>时间</th>
                                                    <th>操作</th>
                                                </tr>
                                                </thead>
                                                <tbody>
                                                {% set i=1 %}
                                                {%for wximg in wximg%}
                                                <tr>
                                                    <td>{{i}}</td>
                                                    <td>{{wximg.title}}</td>
                                                    <td>{{wximg.keyword}}</td>
                                                    <td>{{wximg.click}}</td>
                                                    <td>{{wximg.updatetime}}</td>
                                                    <td>
                                                        <a class="btn btn-primary" href="/admin/appwx/editimg/{{wximg.id}}">编辑</a>
                                                        <button class="btn btn-danger" onclick="deleteConfirm({{wximg.id}});">删除</button>
                                                    </td>
                                                </tr>
                                                {%set i=i+1%}
                                                {%endfor%}
                                                </tbody>
                                            </table>
                                        </div>
                                    </div>
                                </div>
                            </div>

                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
{%endif%}
{%endblock%}{%block end%}
<style type="text/css">
    .def-pan-bd{
        padding: 0 !important;
    }
    .col-title{
        background: #F5F5F5;
        padding: 10px 0;
    }
    .col-title .right{
        text-align: center;
    }
    .col-bd{
        padding: 0 !important;
    }
    .col-bd .form-group{
        margin: 20px 0;
    }
    table * {
        text-align: center;
    }
</style>
<script type="application/javascript">
    $(document).ready(function () {
        $('.select').change(function () {
            var go_href = $(this).val();
            switch (go_href) {
                case "首次关注回复":
                    window.location = "/admin/appwx/reply";
                    break;
                case "文本回复":
                    window.location = "/admin/appwx/text";
                    break;
                case "图文回复":
                    window.location = "/admin/appwx/img";
                    break;
                case "多图文回复":
                    window.location = "/admin/appwx/multi";
                    break;
            }
        });
    });
</script>
<script type="text/javascript">
    function deleteConfirm(delete_id){
        noty({
            text: '确定要删除此图文么?',
            layout: 'topRight',
            buttons: [
                {addClass: 'btn btn-success btn-clean', text: '确定', onClick: function($noty) {
                    $noty.close();
                    $.post('/admin/appwx/delimg/'+delete_id,{},function(result){
//                            console.log("result type--->"+typeof result);
//                            console.log("result--->"+result);


                        noty({text: '删除成功', layout: 'topRight', type: 'success'}
                        );setTimeout(function(){
                            location.reload();
                        },1000);
                    });
                }
                },
                {addClass: 'btn btn-danger btn-clean', text: '取消', onClick: function($noty) {
                    $noty.close();
                }
                }
            ]
        })
    }
</script>
{%endblock%}